<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-07-30 20:02:30
 * @LastEditTime: 2020-02-28 11:25:38
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/fastclick.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <style>
        .box {
            padding: 10px 12px;
        }

        .van-search {
            padding: 0;
        }

        .van-field__control {
            color: #323233;
        }

        .table {
            padding: 8px 0;
        }

        .box .bottom {
            width: 100%;
            display: flex;
        }

        .bottom .van-button {
            margin: auto;
            width: 45%;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="box">
            <van-search v-model="searchVal" show-action placeholder="请输入搜索关键词" @search="onSearch">
                <template #action>
                    <div @click="onSearch">搜索</div>
                </template>
            </van-search>
            <div class="content">
                <div class="table">
                    <table>
                        <tr>
                            <th>类型</th>
                            <th>项目</th>
                            <th>机台</th>
                            <th>产品编号</th>
                            <th>产品名称</th>
                            <th>模具号</th>
                            <th>材料</th>
                            <th>调机员</th>
                            <th>日期</th>
                        </tr>
                        <tr v-for="item in dataList" @click="getItem(item)">
                            <td>{{item.Cate}}</td>
                            <td>{{item.Project}}</td>
                            <td>{{item.MCNO}}</td>
                            <td>{{item.ProductCode}}</td>
                            <td>{{item.ProductName}}</td>
                            <td>{{item.MouldNo}}</td>
                            <td>{{item.Material}}</td>
                            <td>{{item.Operator}}</td>
                            <td>{{item.Date}}</td>
                        </tr>
                    </table>
                </div>
            </div>

            <div class="bottom">
                <van-button size="small" plain color="#e6c678" @click="browserData = {}">取消</van-button>
                <van-button size="small" color="#e6c678" @click="intoTiaoJianKa">确认</van-button>
            </div>
        </div>
    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {
        vm = new Vue({
            el: '#app',
            data: {
                searchVal: '',
                dataList: [],
                browserData: {}
            },
            created: function () {
                var that = this;
                that.onSearch()

                console.log('api', JSON.stringify(api.pageParam))

            },
            methods: {
                onSearch() {
                    var that = this
                    var Type
                    // 试模查询
                    if (api.pageParam.searchType == '试模查询') {
                        that.onSearchTwo()
                    }
                    else {
                        if (api.pageParam.searchType == '历史查询') {
                            Type = 1
                        } else {
                            Type = 0
                        }
                        var obj = {
                            SName: that.searchVal,
                            Type: Type
                        }
                        console.log('obj', JSON.stringify(obj))

                        APP.ajax('GetTJKMessage', obj, function (res) {
                            console.log('res', JSON.stringify(res))
                            if (res.ds.length) {
                                res.ds.map((item) => {
                                    item.Date = item.Date ? (item.Date.split('T')[0] == '1900-01-01' ? '' : item.Date.split('T')[0]) : ''
                                })
                                that.dataList = res.ds
                            } else {
                                api.toast({
                                    msg: '暂无数据！'
                                })
                            }

                        })


                    }

                },

                onSearchTwo() {
                    var that = this

                    var obj = {
                        SName: that.searchVal,
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('GetTJKMessage_SM', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (res.ds.length) {
                            res.ds.map((item) => {
                                item.Date = item.Date ? (item.Date.split('T')[0] == '1900-01-01' ? '' : item.Date.split('T')[0]) : ''
                            })
                            that.dataList = res.ds
                        } else {
                            api.toast({
                                msg: '暂无数据！'
                            })
                        }

                    })
                },

                getItem(row) {
                    var that = this
                    that.browserData = row
                },
                intoTiaoJianKa() {
                    var that = this
                    if (!that.browserData.Location) {
                        api.toast({
                            msg: '请先选择！'
                        })
                        return false
                    }
                    api.sendEvent({
                        name: 'refreshBrowser',
                        extra: {
                            browserData: that.browserData
                        }
                    })
                    api.closeFrame()
                }
            }
        })
    };
</script>

</html>